package com.ruoyi.project.mesworkshop.service.impl;

import java.util.List;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.common.zx.PageData;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.zxmes.md.domain.MdWorkshop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mesworkshop.mapper.MesWorkshopMapper;

/**
 * 车间Service业务层处理
 *
 * @author zx
 * @date 2023-06-06
 */
@Service
public class MesWorkshopServiceImpl extends BaseController{
    @Autowired
    private MesWorkshopMapper mesWorkshopMapper;

    /**
     * 查询车间
     *
     * @param workshop_code 车间主键
     * @return pd
     */

    public PageData selectMesWorkshopByWorkshop_code(String workshop_code){
        return mesWorkshopMapper.selectMesWorkshopByWorkshop_code(workshop_code);
    }

    /**
     * 查询车间列表
     *
     * @param pd
     * @return 车间
     */

    public List<PageData> selectMesWorkshopList(PageData pd){
        pd.put("tenant_id",this.getUserTenantId());
        return mesWorkshopMapper.selectMesWorkshopList(pd);
    }




    /**
     * 获取车间选择框列表
     */

    public List<PageData> selectMesWorkshopType(PageData pd){
        return mesWorkshopMapper.selectMesWorkshopType(pd);
    }




    /**
     * 新增车间
     *
     * @param pd 车间
     * @return 结果
     */
    public int insertMesWorkshop(PageData pd){
        pd.put("tenant_id",this.getUserTenantId());
        pd.put("update_by",this.getUsername());
        pd.put("update_time",DateUtils.getTime());
        pd.put("create_by",this.getUsername());
        pd.put("create_time",DateUtils.getTime());
        return mesWorkshopMapper.insertMesWorkshop(pd);
    }

    /**
     * 修改车间
     *
     * @param pd 车间
     * @return 结果
     */
    public int updateMesWorkshop(PageData pd){
        pd.put("update_by",this.getUsername());
        pd.put("update_time",DateUtils.getTime());
        return mesWorkshopMapper.updateMesWorkshop(pd);
    }

    /**
     * 批量删除车间
     *
     * @param workshop_codes 需要删除的车间主键
     * @return 结果
     */
    public int deleteMesWorkshopByWorkshop_codes(String[] workshop_codes)
    {
        return mesWorkshopMapper.deleteMesWorkshopByWorkshop_codes(workshop_codes);
    }

    /**
     * 删除车间信息
     *
     * @param workshop_code 车间主键
     * @return 结果
     */
    public int deleteMesWorkshopByWorkshop_code(String workshop_code){
        return mesWorkshopMapper.deleteMesWorkshopByWorkshop_code(workshop_code);
    }
}
